package cn.com.homeyoda.aimate.aihealth.ui.health.adapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wzq.mvvmsmart.utils.GlideLoadUtils;

import java.util.ArrayList;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.FamilyMembersBean;
import cn.com.homeyoda.aimate.aihealth.bean.RecommendRecipeBean;

public class MemberSelectAdapter extends BaseQuickAdapter<FamilyMembersBean.DataBean.FamilyMembers, BaseViewHolder> {

    public void setSelectUserId(long selectUserId) {
        this.selectUserId = selectUserId;
    }

    private long selectUserId;

    public MemberSelectAdapter(int layoutResId, @Nullable ArrayList<FamilyMembersBean.DataBean.FamilyMembers> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, FamilyMembersBean.DataBean.FamilyMembers item) {

        if (item.getId() == selectUserId) {
            helper.getConvertView().setBackgroundResource(R.drawable.bg_item_member_select);
        } else {
            helper.getConvertView().setBackgroundResource(R.drawable.shape_white_radius_24);
        }

        GlideLoadUtils.loadImg(helper.getView(R.id.iv_head), item.getAvatar(), R.mipmap.ic_member1);
        helper.setText(R.id.tv_name, item.getName());
        helper.setText(R.id.tv_sex, item.getStringSex());
        helper.setText(R.id.tv_age, item.getAge());
    }

}
